package cn.fivestars.springcloud.commons.entities;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 统一响应
 *
 * @author liangchenzhou1024@163.com
 * @date 2021/2/1
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class CommonResult<T> {
    private int code;

    private String message;

    private T data;

    public CommonResult(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public static <T> CommonResult<T> success(T data) {
        return new CommonResult<>(200, "success", data);
    }

    public static <T> CommonResult<T> failure(int code, String message, T data) {
        return new CommonResult<>(code, message, data);
    }

    public static <T> CommonResult<T> failure(int code, String message) {
        return new CommonResult<>(code, message);
    }



}
